// Written by Steve Andersen, copyright (c) 2007 ONE/Northwest
// This program is released under the GNU General Public License. http://www.gnu.org/licenses/
public class ONEN_Test_HouseholdsAndContacts {
 
	/*********************************************************************************
	* Test creation of one contact. Household should be created and naming should
	* meet expectations
	*********************************************************************************/
	public static testMethod void TestHHForOneContact() {	 
		Id HHId;
		Id FirstContactId;
		//create first contact
		Contact firstContact = new Contact (
			FirstName='Joe',
			LastName='Johanssen',
			OtherStreet='123 Elm St',
			OtherCity='Wauwatosa',
			OtherState='WI', 
			OtherPostalCode='53213',
			Home_County__c='Milwaukee',
			OtherCountry='USA'			
		);
		//system.debug('Insert First Contact');
		insert firstContact;
		
		Contact[] firstHouseholdMember = [select id,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:firstContact.id];
		FirstContactId = firstHouseholdMember[0].id;
		
		ONEN_Household__c[] CurrentHousehold = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:firstHouseholdMember[0].ONEN_Household__c];
		//it should have his address and recognition names on the HH and the Contact record should be right
		HHId = CurrentHousehold[0].Id;
		//one contact in HH?
		System.assertEquals(1,CurrentHousehold[0].Member_Count__c);
		//HH name is as expected?
		System.assertEquals('Joe Johanssen',CurrentHousehold[0].Name);
		//HH greeting is as expected?
		System.assertEquals('Joe',CurrentHousehold[0].Greeting__c);
		//HH name is in sync between contact and HH?
		System.assertEquals(firstHouseholdMember[0].Household_Name__c,CurrentHousehold[0].Name);
		//greeting is in sync between contact and HH
		System.assertEquals(firstHouseholdMember[0].Household_Greeting__c,CurrentHousehold[0].Greeting__c);
		//hh address should be as expected
		System.assertEquals('123 Elm St',CurrentHousehold[0].MailingStreet__c);
		//contact address is as expected
		System.assertEquals('123 Elm St',firstHouseholdMember[0].OtherStreet);
		//address is in sync between contact and HH
		System.assertEquals(firstHouseholdMember[0].OtherStreet, CurrentHousehold[0].MailingStreet__c);	
		
		firstContact.ONEN_Household__c=null;
		update firstContact;
		
		Contact[] firstHouseholdMemberAfterNewHH = [select id,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:firstContact.id];
		System.assertNotEquals(null,firstHouseholdMemberAfterNewHH[0].ONEN_Household__c);
		System.assertNotEquals(HHId,firstHouseholdMemberAfterNewHH[0].ONEN_Household__c);
			
	}

	/*********************************************************************************
	* Test creation of two contacts in a Household. Household should be created and
	* naming should meet expectations
	*********************************************************************************/
	public static testMethod void TestHHForOneContactWithNullValues() {	 
		Id HHId;
		Id FirstContactId;
		//create first contact
		Contact firstContact = new Contact (
			LastName='Johanssen'			
		);
		//system.debug('Insert First Contact');
		insert firstContact;
		
		Contact[] firstHouseholdMember = [select id,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:firstContact.id];
		FirstContactId = firstHouseholdMember[0].id;
		
		ONEN_Household__c[] CurrentHousehold = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:firstHouseholdMember[0].ONEN_Household__c];
		//it should have his address and recognition names on the HH and the Contact record should be right
		HHId = CurrentHousehold[0].Id;
		//one contact in HH?
		System.assertEquals(1,CurrentHousehold[0].Member_Count__c);
		//HH name is as expected?
		System.assertEquals('Johanssen',CurrentHousehold[0].Name);
		//HH greeting is as expected?
		System.assertEquals('Friend',CurrentHousehold[0].Greeting__c);
		//HH name is in sync between contact and HH?
		System.assertEquals(firstHouseholdMember[0].Household_Name__c,CurrentHousehold[0].Name);
		//greeting is in sync between contact and HH
		System.assertEquals(firstHouseholdMember[0].Household_Greeting__c,CurrentHousehold[0].Greeting__c);
		//contact address is as expected
		System.assertEquals(null,firstHouseholdMember[0].OtherStreet);
		//address is in sync between contact and HH
		System.assertEquals(firstHouseholdMember[0].OtherStreet, CurrentHousehold[0].MailingStreet__c);		
		
	}
	/*********************************************************************************
	* Test one contact name change. Household name should change as well.
	*********************************************************************************/
	public static testMethod void TestContactNameChange() {	 
		Id HHId;
		Id FirstContactId;
		//create first contact
		Contact firstContact = new Contact (
			FirstName='Joe',
			LastName='Johanssen',
			OtherStreet='123 Elm St',
			OtherCity='Wauwatosa',
			OtherState='WI',
			OtherPostalCode='53213',
			Home_County__c='Milwaukee',
			OtherCountry='USA'			
		);
		//system.debug('Insert First Contact');
		insert firstContact;
		
		Contact[] firstHouseholdMember = [select id,FirstName,LastName,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:firstContact.id];
		FirstContactId = firstHouseholdMember[0].id;
		
		ONEN_Household__c[] CurrentHousehold = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:firstHouseholdMember[0].ONEN_Household__c];
		HHId = CurrentHousehold[0].Id;
		//names are as expected?
		System.assertEquals('Joe Johanssen',CurrentHousehold[0].Name);
		System.assertEquals('Joe Johanssen',firstHouseholdMember[0].Household_Name__c);
		//greetings are as expected?
		System.assertEquals('Joe',CurrentHousehold[0].Greeting__c);
		System.assertEquals('Joe',firstHouseholdMember[0].Household_Greeting__c);
		
		firstContact.LastName = 'Smith';
		firstContact.FirstName = 'Harry';
		update firstContact;
		
		Contact[] firstHouseholdMember2 = [select id,FirstName,LastName,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:FirstContactId];
				
		ONEN_Household__c[] CurrentHousehold2 = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:HHId];
		
		System.assertEquals('Harry',firstHouseholdMember2[0].FirstName);
		System.assertEquals('Smith',firstHouseholdMember2[0].LastName);
		//names are as expected?
		System.assertEquals('Harry Smith',CurrentHousehold2[0].Name);
		system.debug(firstHouseholdMember2[0].Household_Name__c);
		System.assertEquals('Harry Smith',firstHouseholdMember2[0].Household_Name__c);
		//greetings are as expected?
		System.assertEquals('Harry',CurrentHousehold2[0].Greeting__c);
		System.assertEquals('Harry',firstHouseholdMember2[0].Household_Greeting__c);
		
		Contact secondContact = new Contact (
			FirstName='Allen',
			LastName='Hanson',
			ONEN_Household__c=HHId			
		);
		
		insert secondContact;
		//update the second contact's name
		secondContact.FirstName = 'Bob';
		secondContact.LastName = 'Jones';
		update secondContact;
		
		Contact[] HouseholdMembers = [select id,FirstName,LastName,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where ONEN_Household__c =:HHId];
				
		ONEN_Household__c[] CurrentHousehold3 = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:HHId];
		//first contact should have his own name
		System.assertEquals('Harry',HouseholdMembers[0].FirstName);
		System.assertEquals('Smith',HouseholdMembers[0].LastName);
		//second contact should have his new name
		System.assertEquals('Bob',HouseholdMembers[1].FirstName);
		System.assertEquals('Jones',HouseholdMembers[1].LastName);
		//names are as expected on hh and contacts?
		System.assertEquals('Bob Jones and Harry Smith',CurrentHousehold3[0].Name);
		System.assertEquals('Bob Jones and Harry Smith',HouseholdMembers[0].Household_Name__c);
		System.assertEquals('Bob Jones and Harry Smith',HouseholdMembers[1].Household_Name__c);
		//greetings are as expected on hh and contacts?
		System.assertEquals('Bob and Harry',CurrentHousehold3[0].Greeting__c);
		System.assertEquals('Bob and Harry',HouseholdMembers[0].Household_Greeting__c);
		System.assertEquals('Bob and Harry',HouseholdMembers[1].Household_Greeting__c);
	}
	
	/*********************************************************************************
	* Test creation of two contacts with same last name. They should not be placed
	* in the same Household
	*********************************************************************************/
	public static testMethod void TestTwoSameNameContactsDiffHH() {	 
		Id HHId;
		Id FirstContactId;
		//create first contact
		Contact firstContact = new Contact (
			FirstName='Joe',
			LastName='Johanssen',
			OtherStreet='123 Elm St',
			OtherCity='Wauwatosa',
			OtherState='WI',
			OtherPostalCode='53213',
			Home_County__c='Milwaukee',
			OtherCountry='USA'			
		);
		//system.debug('Insert First Contact');
		insert firstContact;
		
		Id HHId2;
		Id SecondContactId;
		//create first contact
		Contact secondContact = new Contact (
			FirstName='Joe',
			LastName='Johanssen',
			OtherStreet='123 Elm St',
			OtherCity='Wauwatosa',
			OtherState='WI',
			OtherPostalCode='53213',
			Home_County__c='Milwaukee',
			OtherCountry='USA'			
		);
		//system.debug('Insert First Contact');
		insert secondContact;
		
		Contact[] firstHouseholdMember = [select id,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:firstContact.id];
		FirstContactId = firstHouseholdMember[0].id;
		
		
		Contact[] secondHouseholdMember = [select id,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:secondContact.id];
		SecondContactId = secondHouseholdMember[0].id;
		//first and second contact should each have their own HH even though they have the same name
		System.assertNotEquals(firstHouseholdMember[0].ONEN_Household__c, secondHouseholdMember[0].ONEN_Household__c);		
			
	}
	
	/*********************************************************************************
	* Test adding a second contact to a household. Naming and address changes should
	* change as expected
	*********************************************************************************/
	public static testMethod void TestSecondContactInHousehold() {	 
		Id HHId;
		Id HHId2;
		Id FirstContactId;
		Id SecondContactId;
		String firstContactMailingStreet = '123 Elm St';
		String firstContactMailingCity = 'Milwaukee';
		String firstContactMailingState = 'WI';
		String firstContactMailingPostalCode = '53213';
		String firstContactMailingCounty = 'Milwaukee';
		String firstContactMailingCountry = 'USA';
		//create first contact
		Contact firstContact = new Contact (
			FirstName='Joe',
			LastName='Johanssen',
			OtherStreet=firstContactMailingStreet,
			OtherCity=firstContactMailingCity,
			OtherState=firstContactMailingState,
			OtherPostalCode=firstContactMailingPostalCode,
			Home_County__c=firstContactMailingCounty,
			OtherCountry=firstContactMailingCountry			
		);
		insert firstContact;
		Contact[] firstHouseholdMember = [select id,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:firstContact.id];
		FirstContactId = firstContact.id;
		
		//ONEN_Household__c[] CurrentHousehold = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,Name, Greeting__c from ONEN_Household__c where Id =:firstHouseholdMember[0].ONEN_Household__c];
		//it should have his address and recognition names on the HH and the Contact record should be right
		HHId = firstHouseholdMember[0].ONEN_Household__c;
		//create second contact in that household
		String secondContactMailingStreet = '123 Elm St';
		Contact secondContact = new Contact (
			FirstName='Bobby',
			LastName='Johanssen',
			ONEN_Household__c=HHId		
		);
		insert secondContact;
		//there should now be two Contacts in that household
		SecondContactId = secondContact.id;
		System.assertEquals(2,[select count() from Contact where ONEN_Household__c = :HHId]);
		String HHName;
		HHName = 'Bobby and Joe Johanssen';
		String HHGreeting;
		HHGreeting = 'Bobby and Joe';
		ONEN_Household__c[] HHAfterSecondContact = [select id,Member_Count__c, MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:HHId];
		
		//the recognition name on the household should change
		System.assertEquals(2,HHAfterSecondContact[0].Member_Count__c);
		//HHname should be as expected
		System.assertEquals(HHName,HHAfterSecondContact[0].Name);
		System.assertEquals(HHGreeting,HHAfterSecondContact[0].Greeting__c);
		
		//TODO: need assertions for recognition names on both Contacts
		Contact[] ContactAfterSecondContact = [select FirstName, LastName,Household_Greeting__c,Household_Name__c,OtherStreet,OtherCity,OtherState,OtherPostalCode,OtherCountry from Contact where ONEN_Household__c =:HHId];
		//system.debug(ContactAfterSecondContact[0]);
		System.assertEquals(HHName,ContactAfterSecondContact[0].Household_Name__c);
		System.assertEquals(HHGreeting,ContactAfterSecondContact[0].Household_Greeting__c);		
		System.assertEquals(ContactAfterSecondContact[0].Household_Name__c,ContactAfterSecondContact[1].Household_Name__c);
		System.assertEquals(ContactAfterSecondContact[0].Household_Greeting__c,ContactAfterSecondContact[1].Household_Greeting__c);
		//hh mailing address should be
		System.assertEquals(firstContactMailingStreet,HHAfterSecondContact[0].MailingStreet__c);	
		System.assertEquals(firstContactMailingCity,HHAfterSecondContact[0].MailingCity__c);
		System.assertEquals(firstContactMailingState,HHAfterSecondContact[0].MailingState__c);
		System.assertEquals(firstContactMailingPostalCode,HHAfterSecondContact[0].MailingPostalCode__c);
		System.assertEquals(firstContactMailingCountry,HHAfterSecondContact[0].MailingCountry__c);
		System.assertEquals(firstContactMailingCounty,HHAfterSecondContact[0].MailingCounty__c);
		//first contact address should match
		System.assertEquals(firstContactMailingStreet,ContactAfterSecondContact[0].OtherStreet);
		System.assertEquals(firstContactMailingCity,ContactAfterSecondContact[0].OtherCity);
		System.assertEquals(firstContactMailingState,ContactAfterSecondContact[0].OtherState);
		System.assertEquals(firstContactMailingPostalCode,ContactAfterSecondContact[0].OtherPostalCode);
		System.assertEquals(firstContactMailingCountry,ContactAfterSecondContact[0].OtherCountry);
		//second contact address should match
		System.assertEquals(firstContactMailingStreet,ContactAfterSecondContact[1].OtherStreet);
		System.assertEquals(firstContactMailingCity,ContactAfterSecondContact[1].OtherCity);
		System.assertEquals(firstContactMailingState,ContactAfterSecondContact[1].OtherState);
		System.assertEquals(firstContactMailingPostalCode,ContactAfterSecondContact[1].OtherPostalCode);
		System.assertEquals(firstContactMailingCountry,ContactAfterSecondContact[1].OtherCountry);
		
		//what about case where second contact doesn't have address, they should get address
	}
	/*********************************************************************************
	* Test adding a second contact to a household. Naming and address changes should
	* change as expected
	*********************************************************************************/
	public static testMethod void Test3rdContactInHousehold() {	 
		Id HHId;
		Id HHId2;
		Id FirstContactId;
		Id SecondContactId;
		String firstContactMailingStreet = '123 Elm St';
		//create first contact
		Contact firstContact = new Contact (
			FirstName='Joe',
			LastName='Johanssen',
			OtherStreet=firstContactMailingStreet,
			OtherCity='Wauwatosa',
			OtherState='WI',
			OtherPostalCode='53213',
			Home_County__c='Milwaukee',
			OtherCountry='USA'			
		);
		insert firstContact;
		Contact[] firstHouseholdMember = [select id,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:firstContact.id];
		FirstContactId = firstContact.id;
		
		//ONEN_Household__c[] CurrentHousehold = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,Name, Greeting__c from ONEN_Household__c where Id =:firstHouseholdMember[0].ONEN_Household__c];
		//it should have his address and recognition names on the HH and the Contact record should be right
		HHId = firstHouseholdMember[0].ONEN_Household__c;
		//create second contact in that household
		String secondContactMailingStreet = '123 Elm St';
		Contact secondContact = new Contact (
			FirstName='Bobby',
			LastName='Johanssen',
			ONEN_Household__c=HHId		
		);
		insert secondContact;
		
		//there should now be two Contacts in that household
		SecondContactId = secondContact.id;
		System.assertEquals(2,[select count() from Contact where ONEN_Household__c = :HHId]);
		Contact thirdContact = new Contact (
			FirstName='Brad',
			LastName='Johanssen',
			ONEN_Household__c=HHId				
		);
		
		//system.debug('Insert third contact');
		insert thirdContact;
		
		String ExpectedHHName;
		ExpectedHHName = 'The Johanssen Family';
		String ExpectedHHGreeting;
		ExpectedHHGreeting = 'Bobby and Brad and Joe';
		ONEN_Household__c[] HHAfterThirdContact = [select id,Member_Count__c, MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:HHId];
		//recognition names on that second household should change to the more than
		//2 contact notation
		System.assertEquals(firstContactMailingStreet,HHAfterThirdContact[0].MailingStreet__c);
		System.assertEquals(ExpectedHHName,HHAfterThirdContact[0].Name);
		System.assertEquals(ExpectedHHGreeting,HHAfterThirdContact[0].Greeting__c);
		/*
		thirdContact.LastName = 'Jackson';
		update thirdContact;
		
		ONEN_Household__c[] HHAfter7Contact = [select Name, Greeting__c from ONEN_Household__c where Id =:HHId];
		//recognition names on that second household should change to the more than
		//2 contact notation
		System.assertEquals('The Jackson/Johanssen Family',HHAfter7Contact[0].Name);
		System.assertEquals('test',HHAfter7Contact[0].Greeting__c);
		*/
		String OverrideName;
		String OverrideGreeting;
		OverrideName='The Jackhanssens';
		OverrideGreeting='Joe, Bob and Brad';
		ONEN_Household__c firstHH = new ONEN_Household__c (
			Id=HHId,
			Override_Household_Name__c=OverrideName,
			Override_Greeting__c=OverrideGreeting			
		);
		//system.debug('Change greeting and Household Name');
		update firstHH;
		ONEN_Household__c[] HHAfterOverride = [select Name, Greeting__c from ONEN_Household__c where Id =:HHId];
		//HH name should change when overridden
		System.assertEquals(OverrideName,HHAfterOverride[0].Name);
		//HH greeting should change when overridden
		System.assertEquals(OverrideGreeting,HHAfterOverride[0].Greeting__c);
		//add tests for contacts
		Contact[] ContactsInHH = [select FirstName, LastName,Household_Greeting__c,Household_Name__c,OtherStreet,OtherCity,OtherState,OtherPostalCode,OtherCountry from Contact where ONEN_Household__c =:HHId];
		System.assertEquals(OverrideName,ContactsInHH[0].Household_Name__c);
		System.assertEquals(OverrideName,ContactsInHH[1].Household_Name__c);
		System.assertEquals(OverrideGreeting,ContactsInHH[0].Household_Greeting__c);
		System.assertEquals(OverrideGreeting,ContactsInHH[1].Household_Greeting__c);
		
		//change a contact and make sure overrides aren't overridden
		
		ONEN_Household__c HHOverrideNull = new ONEN_Household__c (
			Id=HHId,
			Override_Household_Name__c=null,
			Override_Greeting__c=null			
		);
		//system.debug('Set Overrides back to null');
		
		update HHOverrideNull;
		ONEN_Household__c[] HHAfterOverrideNull = [select Name, Greeting__c from ONEN_Household__c where Id =:HHId];
		//HH name should change when overridden
		System.assertEquals(ExpectedHHName,HHAfterOverrideNull[0].Name);
		//HH greeting should change when overridden
		System.assertEquals(ExpectedHHGreeting,HHAfterOverrideNull[0].Greeting__c);
		//add tests for contacts
		Contact[] ContactsInHHAfterNulling = [select FirstName, LastName,Household_Greeting__c,Household_Name__c,OtherStreet,OtherCity,OtherState,OtherPostalCode,OtherCountry from Contact where ONEN_Household__c =:HHId];
		System.assertEquals(ExpectedHHName,ContactsInHHAfterNulling[0].Household_Name__c);
		System.assertEquals(ExpectedHHName,ContactsInHHAfterNulling[1].Household_Name__c);
		System.assertEquals(ExpectedHHGreeting,ContactsInHHAfterNulling[0].Household_Greeting__c);
		System.assertEquals(ExpectedHHGreeting,ContactsInHHAfterNulling[1].Household_Greeting__c);
		
		//what about case where second contact doesn't have address, they should get address
	}
	
	
	/*********************************************************************************
	* Test creation of one contact and change address. Household address should change
	* as well.
	*********************************************************************************/
	public static testMethod void TestChangeContactAddress() {	 
		Id HHId;
		Id FirstContactId;
		Id SecondContactId;
		String firstContactMailingStreet = '123 Elm St';
		String firstContactMailingCity = 'Milwaukee';
		String firstContactMailingState = 'WI';
		String firstContactMailingPostalCode = '53213';
		String firstContactMailingCounty = 'Milwaukee';
		String firstContactMailingCountry = 'USA';
		
		//create first contact
		Contact firstContact = new Contact (
			FirstName='Joe',
			LastName='Johanssen',
			OtherStreet=firstContactMailingStreet,
			OtherCity=firstContactMailingCity,
			OtherState=firstContactMailingState,
			OtherPostalCode=firstContactMailingPostalCode,
			Home_County__c=firstContactMailingCounty,
			OtherCountry=firstContactMailingCountry			
		);
		insert firstContact;
		
		Contact[] firstHouseholdMember = [select id,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:firstContact.id];
		FirstContactId = firstHouseholdMember[0].id;
		HHId = firstHouseholdMember[0].ONEN_Household__c;
		
		//create second contact in that household
		Contact secondContact = new Contact (
			FirstName='Bobby',
			LastName='Johanssen',
			ONEN_Household__c=HHId		
		);
		insert secondContact;
		
		String secondContactMailingStreet = '12345 Elm St';
		String secondContactMailingCity = 'Toronto';
		String secondContactMailingState = 'ON';
		String secondContactMailingPostalCode = 'V67 F45';
		String secondContactMailingCounty = 'Ontario';
		String secondContactMailingCountry = 'CAN';		
		
		Contact firstContactChanged = new Contact (
			id=FirstContactId,
			OtherStreet=secondContactMailingStreet,
			OtherCity=secondContactMailingCity,
			OtherState=secondContactMailingState,
			OtherPostalCode=secondContactMailingPostalCode,
			Home_County__c = secondContactMailingCounty,
			OtherCountry=secondContactMailingCountry
		);
		update firstContactChanged;
		ONEN_Household__c[] CurrentHousehold = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:HHId];
				
		System.assertEquals(secondContactMailingStreet,CurrentHousehold[0].MailingStreet__c);
		System.assertEquals(secondContactMailingCity,CurrentHousehold[0].MailingCity__c);
		System.assertEquals(secondContactMailingState,CurrentHousehold[0].MailingState__c);
		System.assertEquals(secondContactMailingPostalCode,CurrentHousehold[0].MailingPostalCode__c);
		System.assertEquals(secondContactMailingCountry,CurrentHousehold[0].MailingCountry__c);
		System.assertEquals(secondContactMailingCounty,CurrentHousehold[0].MailingCounty__c);

		Contact[] householdMembersAfterAddressChange = [select id,ONEN_Household__c,OtherStreet,OtherCity,OtherState,OtherPostalCode,OtherCountry from Contact where ONEN_Household__c =:HHId];
		//first contact's addresses should match
		System.assertEquals(secondContactMailingStreet,householdMembersAfterAddressChange[0].OtherStreet);
		System.assertEquals(secondContactMailingCity,householdMembersAfterAddressChange[0].OtherCity);
		System.assertEquals(secondContactMailingState,householdMembersAfterAddressChange[0].OtherState);
		System.assertEquals(secondContactMailingPostalCode,householdMembersAfterAddressChange[0].OtherPostalCode);
		System.assertEquals(secondContactMailingCountry,householdMembersAfterAddressChange[0].OtherCountry);
		//second contact's addresses should match
		System.assertEquals(secondContactMailingStreet,householdMembersAfterAddressChange[1].OtherStreet);
		System.assertEquals(secondContactMailingCity,householdMembersAfterAddressChange[1].OtherCity);
		System.assertEquals(secondContactMailingState,householdMembersAfterAddressChange[1].OtherState);
		System.assertEquals(secondContactMailingPostalCode,householdMembersAfterAddressChange[1].OtherPostalCode);
		System.assertEquals(secondContactMailingCountry,householdMembersAfterAddressChange[1].OtherCountry);
		
		
	}
	
	/*********************************************************************************
	* Test creation of multiple contacts then change Household address. Contact address
	* should change as well
	*********************************************************************************/
	public static testMethod void TestChangeHouseholdAddress() {	 
		Id HHId;
		Id FirstContactId;
		Id SecondContactId;
		String firstContactMailingStreet = '123 Elm St';
		String firstContactMailingCity = 'Milwaukee';
		String firstContactMailingState = 'WI';
		String firstContactMailingPostalCode = '53213';
		String firstContactMailingCounty = 'Milwaukee';
		String firstContactMailingCountry = 'USA';
		
		//create first contact
		Contact firstContact = new Contact (
			FirstName='Joe',
			LastName='Johanssen',
			OtherStreet=firstContactMailingStreet,
			OtherCity=firstContactMailingCity,
			OtherState=firstContactMailingState,
			OtherPostalCode=firstContactMailingPostalCode,
			Home_County__c=firstContactMailingCounty,
			OtherCountry=firstContactMailingCountry			
		);
		insert firstContact;
		
		Contact[] firstHouseholdMember = [select id,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:firstContact.id];
		FirstContactId = firstHouseholdMember[0].id;
		HHId = firstHouseholdMember[0].ONEN_Household__c;
		
		//create second contact in that household
		Contact secondContact = new Contact (
			FirstName='Bobby',
			LastName='Johanssen',
			ONEN_Household__c=HHId		
		);
		insert secondContact;
		
		String newHouseholdMailingStreet = '12345 Elm St';
		String newHouseholdMailingCity = 'Toronto';
		String newHouseholdMailingState = 'ON';
		String newHouseholdMailingPostalCode = 'V67 F45';
		String newHouseholdMailingCounty = 'Ontario';
		String newHouseholdMailingCountry = 'CAN';			
		
		ONEN_Household__c changeHHAddress = new ONEN_Household__c (
			id=HHId,
			MailingStreet__c=newHouseholdMailingStreet,
			MailingCity__c=newHouseholdMailingCity,
			MailingState__c=newHouseholdMailingState,
			MailingPostalCode__c=newHouseholdMailingPostalCode,
			MailingCounty__c = newHouseholdMailingCounty,
			MailingCountry__c=newHouseholdMailingCountry
		);
		update changeHHAddress;
		ONEN_Household__c[] CurrentHousehold = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:HHId];
		
		System.assertEquals(newHouseholdMailingStreet,CurrentHousehold[0].MailingStreet__c);
		System.assertEquals(newHouseholdMailingCity,CurrentHousehold[0].MailingCity__c);
		System.assertEquals(newHouseholdMailingState,CurrentHousehold[0].MailingState__c);
		System.assertEquals(newHouseholdMailingPostalCode,CurrentHousehold[0].MailingPostalCode__c);
		System.assertEquals(newHouseholdMailingCountry,CurrentHousehold[0].MailingCountry__c);
		System.assertEquals(newHouseholdMailingCounty,CurrentHousehold[0].MailingCounty__c);
		
		Contact[] householdMembersAfterAddressChange = [select id,ONEN_Household__c,OtherStreet,OtherCity,OtherState,OtherPostalCode,OtherCountry from Contact where ONEN_Household__c =:HHId];
		//first contact's addresses should match
		System.assertEquals(newHouseholdMailingStreet,householdMembersAfterAddressChange[0].OtherStreet);
		System.assertEquals(newHouseholdMailingCity,householdMembersAfterAddressChange[0].OtherCity);
		System.assertEquals(newHouseholdMailingState,householdMembersAfterAddressChange[0].OtherState);
		System.assertEquals(newHouseholdMailingPostalCode,householdMembersAfterAddressChange[0].OtherPostalCode);
		System.assertEquals(newHouseholdMailingCountry,householdMembersAfterAddressChange[0].OtherCountry);
		//second contact's addresses should match
		System.assertEquals(newHouseholdMailingStreet,householdMembersAfterAddressChange[1].OtherStreet);
		System.assertEquals(newHouseholdMailingCity,householdMembersAfterAddressChange[1].OtherCity);
		System.assertEquals(newHouseholdMailingState,householdMembersAfterAddressChange[1].OtherState);
		System.assertEquals(newHouseholdMailingPostalCode,householdMembersAfterAddressChange[1].OtherPostalCode);
		System.assertEquals(newHouseholdMailingCountry,householdMembersAfterAddressChange[1].OtherCountry);
		
	}
	
	/*********************************************************************************
	* Test deletion of contact from household. Household should be renamed to meet
	* changes in membership
	*********************************************************************************/
	public static testMethod void TestDeleteContactFromHousehold() {	 
		Id HHId;
		Id FirstContactId;
		Id SecondContactId;
		//create first contact
		Contact firstContact = new Contact (
			FirstName='Joe',
			LastName='Johanssen',
			OtherStreet='123 Elm St',
			OtherCity='Wauwatosa',
			OtherState='WI',
			OtherPostalCode='53213',
			Home_County__c='Milwaukee',
			OtherCountry='USA'			
		);
		insert firstContact;
		
		Contact[] firstHouseholdMember = [select id,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:firstContact.id];
		FirstContactId = firstContact.id;
		
		//ONEN_Household__c[] CurrentHousehold = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,Name, Greeting__c from ONEN_Household__c where Id =:firstHouseholdMember[0].ONEN_Household__c];
		//it should have his address and recognition names on the HH and the Contact record should be right
		HHId = firstHouseholdMember[0].ONEN_Household__c;
		//create second contact in that household
		Contact secondContact = new Contact (
			FirstName='Bobby',
			LastName='Johanssen',
			ONEN_Household__c=HHId,
			OtherStreet='123 Elm St',
			OtherCity='Wauwatosa',
			OtherState='WI',
			OtherPostalCode='53213',
			Home_County__c='Milwaukee',
			OtherCountry='USA'			
		);
		insert secondContact;		
		//are two people in hh now?
		System.assertEquals(2,[select count() from Contact where ONEN_Household__c = :HHId]);
		delete secondContact;		
		
		//that household should now have only one Contact in it
		System.assertEquals(1,[select count() from Contact where ONEN_Household__c = :HHId]);
		ONEN_Household__c[] CurrentHousehold = [select id,Member_Count__c,Name, Greeting__c from ONEN_Household__c where Id =:HHId];
		System.assertEquals('Joe Johanssen',CurrentHousehold[0].Name);
		System.assertEquals('Joe',CurrentHousehold[0].Greeting__c);
	}
	
	/*********************************************************************************
	* Test deletion of last contact from household. Household should be deleted when
	* it has no members left
	*********************************************************************************/
	public static testMethod void TestDeleteLastContactFromHousehold() {	 
		Id HHId;
		Id FirstContactId;

		//create first contact
		Contact firstContact = new Contact (
			FirstName='Joe',
			LastName='Johanssen',
			OtherStreet='123 Elm St',
			OtherCity='Wauwatosa',
			OtherState='WI',
			OtherPostalCode='53213',
			Home_County__c='Milwaukee',
			OtherCountry='USA'			
		);
		insert firstContact;
		
		Contact[] firstHouseholdMember = [select id,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:firstContact.id];
		FirstContactId = firstHouseholdMember[0].id;
		ONEN_Household__c[] CurrentHousehold = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:firstHouseholdMember[0].ONEN_Household__c];
		//it should have his address and recognition names on the HH and the Contact record should be right
		HHId = CurrentHousehold[0].Id;
		//hh should exist
		System.assertEquals(1,[select count() from ONEN_Household__c where Id =:HHId]);
		
		delete firstContact;
		//the household should now be deleted since it has no members
		System.assertEquals(0,[select count() from ONEN_Household__c where Id =:HHId]);
		
	}
	
	/*********************************************************************************
	* Test move a contact from one household to another. Both household should be 
	* handled accoring to the change in membership
	*********************************************************************************/
	public static testMethod void TestMoveContactBetweenHouseholds() {	 
		Id HHId;
		Id HHId2;
		Id FirstContactId;
		Id SecondContactId;
		Id ThirdContactId;
		//create first contact
		Contact firstContact = new Contact (
			FirstName='Joe',
			LastName='Johanssen',
			OtherStreet='123 Elm St',
			OtherCity='Wauwatosa',
			OtherState='WI',
			OtherPostalCode='53213',
			Home_County__c='Milwaukee',
			OtherCountry='USA'			
		);
		//system.debug('Insert First Contact');
		insert firstContact;
		Contact[] firstHouseholdMember = [select id,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:firstContact.id];
		FirstContactId = firstContact.id;
		
		//ONEN_Household__c[] CurrentHousehold = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,Name, Greeting__c from ONEN_Household__c where Id =:firstHouseholdMember[0].ONEN_Household__c];
		//it should have his address and recognition names on the HH and the Contact record should be right
		HHId = firstHouseholdMember[0].ONEN_Household__c;
		//create second contact in that household
		Contact secondContact = new Contact (
			FirstName='Bobby',
			LastName='Johanssen',
			ONEN_Household__c=HHId,
			OtherStreet='123 Elm St',
			OtherCity='Wauwatosa',
			OtherState='WI',
			OtherPostalCode='53213',
			Home_County__c='Milwaukee',
			OtherCountry='USA'			
		);
		//system.debug('Insert Second Contact');
		insert secondContact;
		
		SecondContactId = secondContact.Id;
		
		//create a Contact with a new household
		Contact thirdContact = new Contact (
			FirstName='Samuel',
			LastName='Jackson'			
		);		
		//system.debug('Insert Third Contact');
		insert thirdContact;
		ThirdContactId = thirdContact.id;
		
		Contact[] thirdHHMember = [select id,ONEN_Household__c from Contact where Id =:ThirdContactId];
		HHId2 = thirdHHMember[0].ONEN_Household__c;		
		
		//remove the second person from the first Household
		Contact updateSecondContact1 = new Contact (
			id=SecondContactId,
			ONEN_Household__c=HHId2			
		);	
		//test for what happens to first hh	
		//system.debug('Move Second Contact');
		update updateSecondContact1;
		Contact[] bettyMoved = [select id,FirstName, LastName from Contact where id =:SecondContactId];
		//system.assertEquals(HHId2,bettyMoved[0].ONEN_Household__c);
		Contact[] secondHHMembers = [select id,FirstName, LastName from Contact where ONEN_Household__c =:HHId2];
		//system.debug(secondHHMembers);
		
		ONEN_Household__c[] HHAfter4Contact = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:HHId2];
		//recognition names on that second household should change
		//system.debug(HHAfter4Contact[0].Member_Count__c);
		System.assertEquals('Samuel Jackson and Bobby Johanssen',HHAfter4Contact[0].Name);
		
		//if a contact is added to an existing hh, they should inherit the address from the hh
		
		//test that hh disappears if last person is updated out of it
	}
	/*********************************************************************************
	* Test adding a contact with different address values to an existing HH. Should be
	* discarded unless HH address is null
	*********************************************************************************/
	public static testMethod void TestInsertingNewHouseholdMemberWithDifferentAddress() {	
		Id HHId;
		Id HHId2;
		Id FirstContactId;
		Id SecondContactId;
		Id ThirdContactId;
		//create first contact
		Contact firstContact = new Contact (
			FirstName='Joe',
			LastName='Johanssen'		
		);
		//system.debug('Insert First Contact');
		insert firstContact;
		Contact[] firstHouseholdMember = [select id,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:firstContact.id];
		FirstContactId = firstContact.id;
		
		ONEN_Household__c[] CurrentHousehold = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:firstHouseholdMember[0].ONEN_Household__c];
		//all address fields should be null
		system.assertEquals(null,CurrentHousehold[0].MailingStreet__c);
		system.assertEquals(null,CurrentHousehold[0].MailingCity__c);
		system.assertEquals(null,CurrentHousehold[0].MailingState__c);
		system.assertEquals(null,CurrentHousehold[0].MailingPostalCode__c);
		system.assertEquals(null,CurrentHousehold[0].MailingCountry__c);
		system.assertEquals(null,CurrentHousehold[0].MailingCounty__c);		

		HHId = firstHouseholdMember[0].ONEN_Household__c;
		
		String secondContactMailingStreet = '123 Elm St';
		String secondContactMailingCity = 'Milwaukee';
		String secondContactMailingState = 'WI';
		String secondContactMailingPostalCode = '53213';
		String secondContactMailingCounty = 'Milwaukee';
		String secondContactMailingCountry = 'USA';
		
		
		Contact secondContact = new Contact (
			FirstName='Bobby',
			LastName='Johanssen',
			ONEN_Household__c=HHId,
			OtherStreet=secondContactMailingStreet,
			OtherCity=secondContactMailingCity,
			OtherState=secondContactMailingState,
			OtherPostalCode=secondContactMailingPostalCode,
			Home_County__c=secondContactMailingCounty,
			OtherCountry=secondContactMailingCountry			
		);
		//system.debug('Insert Second Contact');
		insert secondContact;
		
		ONEN_Household__c[] CurrentHousehold2 = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:firstHouseholdMember[0].ONEN_Household__c];
		//all address fields should be null
		system.assertEquals(secondContactMailingStreet,CurrentHousehold2[0].MailingStreet__c);
		system.assertEquals(secondContactMailingCity,CurrentHousehold2[0].MailingCity__c);
		system.assertEquals(secondContactMailingState,CurrentHousehold2[0].MailingState__c);
		system.assertEquals(secondContactMailingPostalCode,CurrentHousehold2[0].MailingPostalCode__c);
		system.assertEquals(secondContactMailingCountry,CurrentHousehold2[0].MailingCountry__c);
		system.assertEquals(secondContactMailingCounty,CurrentHousehold2[0].MailingCounty__c);
		
		Contact[] HouseholdMembers = [select id,ONEN_Household__c,OtherStreet,OtherCity,OtherState,OtherPostalCode,OtherCountry, Account.Name, Household_Greeting__c,Household_Name__c from Contact where ONEN_Household__c =:HHId];
		//address should match on first contact
		system.assertEquals(secondContactMailingStreet,HouseholdMembers[0].OtherStreet);
		system.assertEquals(secondContactMailingCity,HouseholdMembers[0].OtherCity);
		system.assertEquals(secondContactMailingState,HouseholdMembers[0].OtherState);
		system.assertEquals(secondContactMailingPostalCode,HouseholdMembers[0].OtherPostalCode);
		system.assertEquals(secondContactMailingCountry,HouseholdMembers[0].OtherCountry);
		//address should match on second contact
		system.assertEquals(secondContactMailingStreet,HouseholdMembers[1].OtherStreet);
		system.assertEquals(secondContactMailingCity,HouseholdMembers[1].OtherCity);
		system.assertEquals(secondContactMailingState,HouseholdMembers[1].OtherState);
		system.assertEquals(secondContactMailingPostalCode,HouseholdMembers[1].OtherPostalCode);
		system.assertEquals(secondContactMailingCountry,HouseholdMembers[1].OtherCountry);
		
		Contact thirdContact = new Contact (
			FirstName='Samuel',
			LastName='Jackson',
			ONEN_Household__c=HHId		
		);		
		//system.debug('Insert Third Contact');
		insert thirdContact;
		
		ONEN_Household__c[] CurrentHousehold3 = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:firstHouseholdMember[0].ONEN_Household__c];
		//all address fields should be null
		system.assertEquals(secondContactMailingStreet,CurrentHousehold3[0].MailingStreet__c);
		system.assertEquals(secondContactMailingCity,CurrentHousehold3[0].MailingCity__c);
		system.assertEquals(secondContactMailingState,CurrentHousehold3[0].MailingState__c);
		system.assertEquals(secondContactMailingPostalCode,CurrentHousehold3[0].MailingPostalCode__c);
		system.assertEquals(secondContactMailingCountry,CurrentHousehold3[0].MailingCountry__c);
		system.assertEquals(secondContactMailingCounty,CurrentHousehold3[0].MailingCounty__c);	
		
		Contact[] HouseholdMembers2 = [select id,ONEN_Household__c,OtherStreet,OtherCity,OtherState,OtherPostalCode,OtherCountry, Account.Name, Household_Greeting__c,Household_Name__c from Contact where ONEN_Household__c =:HHId];
		//address should match on first contact
		system.assertEquals(secondContactMailingStreet,HouseholdMembers2[0].OtherStreet);
		system.assertEquals(secondContactMailingCity,HouseholdMembers2[0].OtherCity);
		system.assertEquals(secondContactMailingState,HouseholdMembers2[0].OtherState);
		system.assertEquals(secondContactMailingPostalCode,HouseholdMembers2[0].OtherPostalCode);
		system.assertEquals(secondContactMailingCountry,HouseholdMembers2[0].OtherCountry);
		//address should match on second contact
		system.assertEquals(secondContactMailingStreet,HouseholdMembers2[1].OtherStreet);
		system.assertEquals(secondContactMailingCity,HouseholdMembers2[1].OtherCity);
		system.assertEquals(secondContactMailingState,HouseholdMembers2[1].OtherState);
		system.assertEquals(secondContactMailingPostalCode,HouseholdMembers2[1].OtherPostalCode);
		system.assertEquals(secondContactMailingCountry,HouseholdMembers2[1].OtherCountry);
		//address should match on third contact
		system.assertEquals(secondContactMailingStreet,HouseholdMembers2[2].OtherStreet);
		system.assertEquals(secondContactMailingCity,HouseholdMembers2[2].OtherCity);
		system.assertEquals(secondContactMailingState,HouseholdMembers2[2].OtherState);
		system.assertEquals(secondContactMailingPostalCode,HouseholdMembers2[2].OtherPostalCode);
		system.assertEquals(secondContactMailingCountry,HouseholdMembers2[2].OtherCountry);
	}
	/*********************************************************************************
	* Test moving a contact with different address values into an existing HH.
	*********************************************************************************/
	public static testMethod void TestMovingHouseholdMemberWithDifferentAddress() {
			
		Id HHId;
		Id HHId2;
		Id FirstContactId;
		Id SecondContactId;
		Id ThirdContactId;
		//create first contact
		Contact firstContact = new Contact (
			FirstName='Joe',
			LastName='Johanssen'
		);
		//system.debug('Insert First Contact');
		insert firstContact;
		Contact[] firstHouseholdMember = [select id,ONEN_Household__c,OtherStreet,Account.Name, Household_Greeting__c,Household_Name__c from Contact where Id =:firstContact.id];
		FirstContactId = firstContact.id;
		
		ONEN_Household__c[] CurrentHousehold = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:firstHouseholdMember[0].ONEN_Household__c];
		//all address fields should be null
		system.assertEquals(null,CurrentHousehold[0].MailingStreet__c);
		system.assertEquals(null,CurrentHousehold[0].MailingCity__c);
		system.assertEquals(null,CurrentHousehold[0].MailingState__c);
		system.assertEquals(null,CurrentHousehold[0].MailingPostalCode__c);
		system.assertEquals(null,CurrentHousehold[0].MailingCountry__c);		
		system.assertEquals(null,CurrentHousehold[0].MailingCounty__c);

		HHId = firstHouseholdMember[0].ONEN_Household__c;
		
		String secondContactMailingStreet = '123 Elm St';
		String secondContactMailingCity = 'Milwaukee';
		String secondContactMailingState = 'WI';
		String secondContactMailingPostalCode = '53213';
		String secondContactMailingCounty = 'Milwaukee';
		String secondContactMailingCountry = 'USA';
		
		
		Contact secondContact = new Contact (
			FirstName='Bobby',
			LastName='Johanssen',
			OtherStreet=secondContactMailingStreet,
			OtherCity=secondContactMailingCity,
			OtherState=secondContactMailingState,
			OtherPostalCode=secondContactMailingPostalCode,
			Home_County__c = secondContactMailingCounty,
			OtherCountry=secondContactMailingCountry			
		);
		//system.debug('Insert Second Contact');
		insert secondContact;
		
		secondContact.ONEN_Household__c=HHId;
		
		update secondContact;
		
		Contact[] HouseholdMembers = [select id,FirstName,ONEN_Household__c,OtherStreet,OtherCity,OtherState,OtherPostalCode,OtherCountry, Account.Name, Household_Greeting__c,Household_Name__c from Contact where ONEN_Household__c =:HHId];
		//address should match on first contact
		system.assertEquals(secondContactMailingStreet,HouseholdMembers[0].OtherStreet);
		system.assertEquals(secondContactMailingCity,HouseholdMembers[0].OtherCity);
		system.assertEquals(secondContactMailingState,HouseholdMembers[0].OtherState);
		system.assertEquals(secondContactMailingPostalCode,HouseholdMembers[0].OtherPostalCode);
		system.assertEquals(secondContactMailingCountry,HouseholdMembers[0].OtherCountry);
		//address should match on second contact
		system.assertEquals(secondContactMailingStreet,HouseholdMembers[1].OtherStreet);
		system.assertEquals(secondContactMailingCity,HouseholdMembers[1].OtherCity);
		system.assertEquals(secondContactMailingState,HouseholdMembers[1].OtherState);
		system.assertEquals(secondContactMailingPostalCode,HouseholdMembers[1].OtherPostalCode);
		system.assertEquals(secondContactMailingCountry,HouseholdMembers[1].OtherCountry);
		
		ONEN_Household__c[] firstHouseholdAfterUpdate = [select id,Member_Count__c,MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c,MailingCounty__c,Name, Greeting__c from ONEN_Household__c where Id =:HHId];
		system.assertEquals(secondContactMailingStreet,firstHouseholdAfterUpdate[0].MailingStreet__c);
		system.assertEquals(secondContactMailingCity,firstHouseholdAfterUpdate[0].MailingCity__c);
		system.assertEquals(secondContactMailingState,firstHouseholdAfterUpdate[0].MailingState__c);
		system.assertEquals(secondContactMailingPostalCode,firstHouseholdAfterUpdate[0].MailingPostalCode__c);
		system.assertEquals(secondContactMailingCountry,firstHouseholdAfterUpdate[0].MailingCountry__c);
		system.assertEquals(secondContactMailingCounty,firstHouseholdAfterUpdate[0].MailingCounty__c);
	
	}
	
}